#include "HTTPRequest.h" #include "PipeSegment.h" class HTTPRequestHandler : public IHTTPRequestHandler, //the object itself "is a" IHTTPRequestHandler //and it only outputs to IHTTPRequestHandler objects public PipeLineProcessing::PipeSegment { public: virtual void HandleHTTPRequest(HTTPRequest *request) { //Since the HTTPRequestHandler object does nothing besides //send the request off to any connected request handlers, //this method simply iterates over the collection of output //handlers currently "connected to" this object. for (int i=0; i < (int)this->theOutput.size(); i++) { IHTTPRequestHandler *anOutputHandler = (IHTTPRequestHandler *)this->theOutput.at(i); anOutputHandler->HandleHTTPRequest(request); } }; }; class HTTPRequestAuthenticator : public IHTTPRequestHandler, //the object itself "is a" IHTTPRequestHandler //and it only outputs to IHTTPRequestHandler objects public PipeLineProcessing::PipeSegment { private: bool requestIsAuthentic(HTTPRequest *request) { return true; }; //everyone's authenticated! public: virtual void HandleHTTPRequest(HTTPRequest *request) { //This object only passes the HTTPRequest down the //pipeline if the request is successfully authenticated if (requestIsAuthentic(request)) { for (int i=0; i < (int)this->theOutput.size(); i++) { IHTTPRequestHandler *anOutputHandler = (IHTTPRequestHandler *)this->theOutput.at(i); anOutputHandler->HandleHTTPRequest(request); } } } };